home *** CD-ROM | disk | FTP | other *** search
- Path: cypher.3do.com!user
- From: tsw@3do.com (Tom Watson)
- Newsgroups: comp.lang.c
- Subject: Re: HELP...HELP
- Date: Tue, 16 Apr 1996 12:03:47 -0800
- Organization: The 3DO Corporation
- Distribution: world
- Message-ID: <tsw-1604961203470001@cypher.3do.com>
- References: <316EF6A1.41C6@ift.ulaval.ca>
- NNTP-Posting-Host: cypher.3do.com
-
- In article <316EF6A1.41C6@ift.ulaval.ca>, Ferid Baklouti
- <baklouti@ift.ulaval.ca> wrote:
-
- > Hello everyone,
- >
- > imagine this command under a unix system :
- >
- > program1 < file | program2 | program3 > file.results
- >
- > i want the "program2" to be able to detect the name of "file" given on
- > the standard input <stdin> to the program1.
- >
- >
- >
- > in the file stdio.h, I only find the things below which doesn't contain
- > the name of the file.
- <<<copy of his <stdio.h> deleted>>>
-
- The association of the file with a standard I/O stream is outside the
- scope of the <stdio.h> functions (and standard C for that matter). Once
- the file has been opened for input (in your example 'program1') the
- association of a name with the stream (FILE structure) is lost. In your
- pipeline example above, even 'program1' doesn't know what the name of its
- input is since the invoking program (the shell in Unix) is the one that
- associated the file name 'file' with the input stream.
-
- All you know is that the data is coming from "somewhere" and where is none
- of your concern, nor need it be any of your concern. About the only thing
- you can tell (with calls to Unix functions) is that you are dealing with a
- device, or a file. The information is not available if you are using the
- <stdio.h> library.
-
- Now, if you desire to invoke your set of programs with the name 'file' and
- have the final output as 'file.results' (as in the example above), I would
- suggest a small shell script that takes an argument. To do that is a
- topic for shell scripting and not part of the 'comp.lang.c' newsgroup.
-
- Short answer: "You can't do that!".
-
- --
- Tom Watson
- tsw@3do.com (Home: tsw@johana.com)
-